package javahomework;

import java.util.Arrays;

//将数组元素从小到大排列序(希尔排序)
public class text3 {

	    public static void main(String[] args){
	        int []array={48,5,89,80,81,23,45,16,2};
	       // int foot=4;
	        System.out.println("排序前："+ Arrays.toString(array));
	        for (int foot = 4; foot >0 ; foot/=2) {
	            for (int i = foot; i < array.length; i++) {
	                for (int j = i; j > foot-1; j-=foot) {
	                    if(array[j-foot]>array[j]){
	                        int center=array[j-foot];
	                        array[j-foot]=array[j];
	                        array[j]=center;
	                    }
	                }
	            }
	            System.out.println("步长增量为"+foot+"希尔排序后的结果"+Arrays.toString(array));
	        }
	    }
	}

